from . import serializers
from rest_framework.generics import ListAPIView
from . import models as home_models
from product import models
from django_filters.rest_framework import DjangoFilterBackend


class BannerListAPIView(ListAPIView):
    serializer_class = serializers.BannerSerializers
    queryset = home_models.Banner.objects.filter(is_delete=False,is_show=True).order_by('-orders')


class ProductListAPIView(ListAPIView):
    queryset = models.Product_category.objects.filter(is_delete=False,is_show=True,is_home=True).order_by('-orders')
    serializer_class = serializers.CategoryModelSerializer

class CountryListAPIView(ListAPIView):
    queryset = models.Country.objects.filter(is_delete=False,is_show=True).order_by('-orders')
    serializer_class = serializers.CountryModelSerializers


class NavCategoryListAPIView(ListAPIView):
    queryset = models.Product_category.objects.filter(is_delete=False,is_show=True,is_home=False).order_by('-orders')
    serializer_class = serializers.CategoryModelSerializer
    filter_backends = [DjangoFilterBackend]
    filter_fields = ['id', ]


class PlaceListAPIView(ListAPIView):
    queryset = models.Place.objects.filter(is_delete=False,is_show=True).order_by('-orders')
    serializer_class = serializers.PlaceModelSerializer